<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>OSS</title>
	<link rel="stylesheet" href="../../js/layui/css/layui.css" />
	<link rel="stylesheet" href="../../css/layui-blue.css" />
	<script type="text/javascript" src="../../js/layui/layui.all.js" ></script>
</head>
<body style="padding:5px;">
<a class="layui-btn layui-btn-sm layui-btn-normal" href="ossForm.html"><i class="layui-icon">&#xe654;</i> 添加OSS配置</a>
<hr>
<table class="layui-table" id="table" lay-filter="table"></table>
<script>
	var $ = layui.$;
	var $table = layui.table.render({
		id : 'table',
		elem : '#table',
		url : '/oss/list',
		page : true,
		parseData : function(resp){
			return {
				code : 0,
				data : resp.records,
				count : resp.total
			}
		},
		cols : [[{
			title : '序号',
			type : 'numbers',
			align : 'center'
		},{
			title : '主键',
			field : 'ossId',
			align : 'center'
		},{
			title : 'EndPoint（地域节点）',
			field : 'endpoint',
			align : 'center'
		},{
			title : 'ACCESS_KEY_ID',
			field : 'accessKeyId',
			align : 'center'
		},{
			title : 'ACCESS_KEY_SECRET',
			field : 'accessKeySecret',
			align : 'center'
		},{
			title : 'Bucket 名称',
			field : 'bucketName',
			align : 'center'
		},{
			title : '操作',
			align : 'center',
			templet : '#buttons'
		}]]
	})
	$("body").on('click','.btn-remove',function(){
		var id = $(this).data('id');
		layui.layer.confirm('您确定要删除此OSS配置吗？',{
			title : '删除'
		},function(index){
			$table.reload();
			$.ajax({
				url : '/oss/delete',
				data : {
					id : id
				},
				success : function(){
					layui.layer.msg('删除成功',{time : 500},function(){
						$table.reload();
					})
				},
				error : function(){
					layui.layer.msg('删除失败')
				}
			})
			layui.layer.close(index);
		})
	}).on('click','.btn-edit',function(){
		location.href = 'ossForm.html?id=' + $(this).data('id');
	})
</script>
<script type="text/html" id="buttons">
	<a class="layui-btn layui-btn-sm btn-edit" data-id="{{d.ossId}}">编辑</a>
	<a class="layui-btn layui-btn-sm btn-remove" data-id="{{d.ossId}}">删除</a>
</script>
</body>
</html>